package com.pkk.cloud.support.admin.service;

import com.github.pagehelper.PageInfo;
import com.pkk.cloud.support.admin.dto.req.client.OauthClientDelReqDto;
import com.pkk.cloud.support.admin.dto.req.client.OauthClientIdReqDto;
import com.pkk.cloud.support.admin.dto.req.client.OauthClientPageReqDto;
import com.pkk.cloud.support.admin.dto.req.client.OauthVisitClientBindClientScopeReqDto;
import com.pkk.cloud.support.admin.dto.resp.client.OauthClientDetailRespDto;
import com.pkk.cloud.support.admin.dto.resp.server.OauthServerClientByClientVistiRespDto;
import com.pkk.cloud.support.admin.dto.resp.server.OauthServerClientScopeByClientRespDto;
import com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient;
import com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClientScope;
import com.pkk.components.rpc.page.Page;
import java.util.List;
import java.util.Set;

/**
 * @description: 客户端和sope的业务类
 * @author: peikunkun
 * @create: 2020-03-30 15:48
 **/
public interface PenguinSysClientScopeBusinessService {


  /**
   * @Description: 保存oauth的客户端的信息
   * @Param: penguinOauthClient
   * @return: boolean
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 上午 11:07
   */
  boolean saveOauth2Client(PenguinOauthClient penguinOauthClient);

  /**
   * @Description: 保存服务客户端操作
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:00
   */
  int savePenguinOauthClient(PenguinOauthClient record);

  /**
   * @Description: 获取客户端信息依据id
   * @Param: id
   * @return: com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:01
   */
  PenguinOauthClient selectPenguinOauthClientById(Integer id);

  /**
   * @Description: 更具id更新客户端信息
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:02
   */
  int updatePenguinOauthClientById(PenguinOauthClient record);

  /**
   * @Description: 验证是否存在客户端
   * @Param: clientType
   * @Param clientId
   * @Param ownServerId
   * @return: boolean
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 上午 11:33
   */
  boolean countClientExists(Integer clientType, String clientId, Long ownServerId, Long excludeId);


  /**
   * @Description: 保存客户端授权scope信息
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:10
   */
  boolean insertPenguinOauthClientScope(PenguinOauthClientScope record);

  /**
   * @Description: 依据id查询客户端的授权范围的信息
   * @Param: id
   * @return: com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClientScope
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:10
   */
  PenguinOauthClientScope selectPenguinOauthClientScopeById(Long id);

  /**
   * @Description: 更新授权范围的信息依据id
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:11
   */
  boolean updateByPrimaryKeySelective(PenguinOauthClientScope record);

  /**
   * @Description: 获取客户端/客户访问端详情分页查询
   * @Param: page
   * @Param body
   * @return: com.github.pagehelper.PageInfo<com.pkk.cloud.support.admin.dto.resp.client.OauthClientPageRespDto>
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:15
   */
  PageInfo<OauthClientDetailRespDto> findOauthClientPage(Page page, OauthClientPageReqDto body);

  /**
   * @Description: 删除客户端依据id
   * @Param: body
   * @return: boolean
   * @Author: peikunkun
   * @Date: 2020/4/1 0001 下午 4:06
   */
  boolean updateOauthClientCloseById(OauthClientDelReqDto body, String userId);

  /**
   * @Description: 更新客户端信息依据id
   * @Param: body
   * @return: boolean
   * @Author: peikunkun
   * @Date: 2020/4/1 0001 下午 6:34
   */
  boolean updateOauthClientById(PenguinOauthClient client);

  /**
   * @Description: 获取客户端信息依据id
   * @Param: id
   * @return: com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient
   * @Author: peikunkun
   * @Date: 2020/4/2 0002 下午 1:49
   */
  PenguinOauthClient getOauthClientById(Long id);

  /**
   * @Description: 依据id查询客户端详细信息
   * @Param: body
   * @Author: peikunkun
   * @Date: 2020/4/5 0005 下午 3:12
   */
  OauthClientDetailRespDto findClientById(OauthClientIdReqDto body);

  /**
   * @Description: 获取所有的客户端
   * @Param:
   * @return: java.util.List<com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient>
   * @Author: peikunkun
   * @Date: 2020/4/8 下午9:47
   */
  List<PenguinOauthClient> findAllClientView();

  /**
   * @Description: 获取用户客户端详情依据用户id
   * @Param: userId
   * @return: java.util.List<com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient>
   * @Author: peikunkun
   * @Date: 2020/4/8 下午9:56
   */
  List<PenguinOauthClient> findUserClientView(Long userId);

  /**
   * @Description: 获取访问客户端的服务组以及服务组下面的客户端信息【服务端->客户端】
   * @Author: peikunkun
   * @Date: 2020/4/22 下午4:21
   */
  List<OauthServerClientScopeByClientRespDto> getBindServerClientByClientId(String clientId);

  /**
   * @Description: 获取客户端的授权对象
   * @Param: clientId
   * @return: java.util.Set<java.lang.String>
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 4:42
   */
  Set<String> findClientScopeByClientId(String clientId);

  /**
   * @Description: 绑定客户端的授权服务
   * @Param: clientId
   * @Param scope
   * @return: boolean
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 5:25
   */
  boolean bindClientScope(String clientId, Set<String> scopes);

  /**
   * @Description: 获取访问客户端的客户端绑定信息
   * @Param: request
   * @return: com.pkk.components.rpc.response.CommonResponse
   * @Author: peikunkun
   * @Date: 2020/4/24 0024 上午 10:07
   */
  List<OauthServerClientByClientVistiRespDto> findVisitClientBindInfo(String visitClientId);

  /**
   * @Description: 访问客户端授权客户端操作
   * @Param: body
   * @return: java.lang.Boolean
   * @Author: peikunkun
   * @Date: 2020/4/24 0024 上午 10:40
   */
  Boolean visitClientBindClientScope(OauthVisitClientBindClientScopeReqDto body);

}
